<?php

@session_start();
//swift
require_once("libs/swift/swift_required.php");

class Payment_error extends Controller {

    function __construct() {
        parent::__construct();
    }

    function index() {


        // echo 'in';exit;
        $sql = new sql();
        $sql->connect();
        $GETID = getId();
     //   if (array_key_exists('1', getId())) {
           // $GETID = getId();
           // $user_id = $GETID[1];
            
          //  $UserArray = $sql->fetch("tbl_user", array("user_id" => $user_id));

        $UserArray = $_SESSION['CHECKOUT_DATA'];
        $user_firstname = $UserArray['user_firstname'];
        $user_email = $UserArray['user_email'];

            //errorURL .

            ob_start();
            include_once('mail/paypal_error.php');
            $output = ob_get_contents();
            ob_end_clean();
           
            // Create the mail transport configuration
            $transport = Swift_MailTransport::newInstance();
            $mailMessage = Swift_Message::newInstance()
                    ->setSubject('TechOak Payment Error')
                    ->setFrom(array(ADMIN_EMAIL => ADMIN_NAME))
                    ->setTo(
                            array(
                                $UserArray['user_email'] => $UserArray['user_prefix'] . " " . $UserArray['user_firstname'] . " " . $UserArray['user_lastname'],
                            //$filterElements['email'] => $filterElements['name'] 
                    ))
                    //->setCc(array('support@techoak.com' => 'techoak'))
                    ->setCc(array('wikitudedeveloper@gmail.com' => 'techoak'))
                    ->setBody($output, 'text/html');
            // Send the email
            $mailer = Swift_Mailer::newInstance($transport);
            //$mailer->send($mailMessage);


            $this->view->allOrderArray = $UserArray;
            $this->view->render('payment_error');
        }
   // }
}